home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
iqb9107.zip
/
INSRTDSK.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-05-24
|
2KB
|
61 lines
' InsrtDsk.Bas
' $INCLUDE: 'QB.BI'
CONST FALSE = 0, TRUE = NOT FALSE
DIM Regs AS RegTypeX
DIM AH AS INTEGER
' Although the Verify Sector operation transfers no disk data,
' the specifications require a valid transfer buffer equal in
' size to the number of sectors times the sector size. Since
' virtually all diskettes use a sector size of 512 bytes, and
' we are just verifying one sector, we need a buffer of 256.
DIM DummyBuffer(256) AS INTEGER
Tries% = 1 ' counter for number of Verify attempts
Done% = FALSE ' flag to control Verify attempt loop
Drive% = 0 ' 0=drive A, 1=drive B, etc.
NSectors% = 1 ' number of sectors to verify
Cylinder% = 0 ' disk cylinder number
Sector% = 1 ' disk sector number
Head% = 0 ' disk head number
' Make a string version of the drive to use in PRINT statements
DriveLetter$ = CHR$(ASC("A") + Drive%)
' Prompt the user to insert a diskette in the drive
PRINT "Please place a formatted floppy disk in drive ";
PRINT DriveLetter$; "..."
DO
' Set up the input parameters for the Verify Sector operation
Regs.AX = &H4 * 256 OR NSectors%
Regs.CX = Cylinder% * 256 OR Sector%
Regs.DX = Head% * 256 OR Drive%
Regs.ES = VARSEG(DummyBuffer(0))
Regs.BX = VARPTR(DummyBuffer(0))
' Issue the Low-level DIsk I/O interrupt
InterruptX &H13, Regs, Regs
' Check for an error status
IF Regs.flags AND 1 THEN
AH = (Regs.AX \ 256) AND &HFF
'PRINT "Error status is "; HEX$(AH)
Tries% = Tries% + 1
' Reset the drive, in case the motor was off...
Regs.AX = 0
Regs.DX = Drive%
InterruptX &H13, Regs, Regs
ELSE
AH = 0 ' clear any previous error
Done% = TRUE ' yes, we're done!
END IF
LOOP UNTIL Done% OR Tries% > 3
' Now interpret the result
IF AH <> 0 THEN
PRINT "Cannot read drive ";
PRINT DriveLetter$;
PRINT ", status is "; HEX$(AH)
ELSE
PRINT "There is a formatted disk in drive ";
PRINT DriveLetter$
PRINT "It took "; Tries%; " tries to get the disk spun-up."
END IF
END